


<%@page pageEncoding="UTF-8" contentType="text/html; UTF-8" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>学生列表</title>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/back/statics/css/bootstrap.min.css">
	 <style>
        .form-control {
            height: 30px;
        }

        .pagination {
            margin-top: 0px;
        }
    </style>
</head>
<body >
<div class="container-fluid">
    <div class="row">
        <div class="col-sm-12" style="text-align: center">
            <form class="form-inline" action="${pageContext.request.contextPath}/student/queryAll" method="post">
                <div class="form-group">
                    <label>请选择:</label>
                    <select class="form-control" style="height: 30px; width: 100px;" name="column">
                        <option value="name">姓名</option>
                        <option value="phone">手机</option>
                        <option value="qq">QQ</option>
                    </select>
                    <input type="text" class="form-control" name="value" style="height: 30px; width: 300px;">
                </div>

                <button type="submit" class="btn btn-primary btn-sm">搜索</button>
            </form>
        </div>
    </div>
    <div class="row" style="margin-top: 15px;height: 300px">

            <div class="col-sm-12" style="margin-bottom: 10px;">
                <a href="${pageContext.request.contextPath}/student/queryTags" class="btn btn-sm btn-success">添加学生信息</a>
            </div>

        <div class="col-sm-12">
                <table class="table table-hover table-bordered table-striped">
                    <thead>
                    <tr>
                        <th>姓名</th>
                        <th>电话</th>
                        <th>年龄</th>
                        <th>生日</th>
                        <th>生肖</th>
                        <th>星座</th>
                        <th>班级</th>
                        <th>小组</th>
                        <th>就业城市</th>
                        <th>标签</th>
                        <th>操作</th>
                    </tr>
                    </thead>



                    <c:forEach items="${students}" var="student">
                        <tr>
                            <td>${student.name}</td>
                            <td>${student.phone}</td>
                            <td>${student.age}</td>
                            <td><fmt:formatDate value="${student.birthday}" pattern="yyyy-MM-dd"/></td>
                            <td>${student.attr}</td>
                            <td>${student.stars}</td>
                            <td>${student.clazz.name}</td>
                            <td>${student.group.name}</td>
                            <td>${student.city.name}</td>
                            <td>
                                <c:forEach items="${student.tags}" var="tag">
                                    <span class="label label-info">${tag.name}</span>
                                </c:forEach>
                            </td>
                            <td>

                                <c:if test="${sessionScope.role=='admin'}">
                                    <a href="${pageContext.request.contextPath}/student/queryStudent?id=${student.id}" class="btn btn-warning btn-sm">修改</a>
                                    <a href="${pageContext.request.contextPath}/student/remove?id=${student.id}" class="btn btn-danger btn-sm">删除</a>
                                </c:if>

                            </td>
                        </tr>
                    </c:forEach>


                </table>
        </div>
    </div>

    <c:if test="${requestScope.total!=0}">
        <div class="row">
            <div class="col-sm-8">
                    <a href=""
                       class="btn btn-sm btn-info">下载学生信息到文件中</a>
            </div>
            <div class="col-sm-4">
                <nav aria-label="Page navigation">
                    <ul class="pagination">

                        <li>
                        <%--判断上一页--%>
                        <c:if test="${requestScope.pageIndex > 1}">
                            <a href="${pageContext.request.contextPath}/student/queryAll?pageIndex=${pageIndex-1}"
                               aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </c:if>

                            <c:if test="${requestScope.pageIndex <= 1}">
                                <a href="#"
                                   aria-label="Previous">
                                    <span aria-hidden="true">&laquo;</span>
                                </a>
                            </c:if>
                        </li>


                        <li>
                                <%--遍历页号--%>
                            <c:forEach var="page" begin="1" end="${requestScope.maxPageIndex}">
                                <a href="${pageContext.request.contextPath}/student/queryAll?pageIndex=${page}"> ${page}  </a>
                            </c:forEach>
                        </li>



                        <li>
                        <%--判断下一页--%>
                        <c:if test="${requestScope.pageIndex < requestScope.maxPageIndex}">
                            <a href="${pageContext.request.contextPath}/student/queryAll?pageIndex=${pageIndex+1}"
                               aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </c:if>
                        </li>

                        <li>
                            <c:if test="${requestScope.pageIndex >= requestScope.maxPageIndex}">
                                <a href="#"
                                   aria-label="Next">
                                    <span aria-hidden="true">&raquo;</span>
                                </a>
                            </c:if>

                        </li>
                    </ul>
                </nav>
            </div>
        </div>
    </c:if>
</div>
</body>
</html>
